<html>
<head>
<!-- Get the style sheet for the theme defined in globals.php -->
<!--<link rel="stylesheet" href="[-php-]echo $GLOBALS['css_header'][-/php-]" type="text/css">-->


[-if $cal_ui eq 3-]
<!-- this style sheet is used for the ajax_* style calendars -->
<link rel="stylesheet" href="[-php-]echo $GLOBALS['webroot'].'/interface/themes/ajax_calendar.css';[-/php-]" type="text/css">
<!--[if IE]>
        <link rel="stylesheet" href="[-php-]echo $GLOBALS['webroot'].'/interface/themes/ajax_calendar_ie.css';[-/php-]" type="text/css"/>
<![endif]-->

<!-- the javascript used for the ajax_* style calendars -->
<script type="text/javascript" src="[-php-] echo $GLOBALS['webroot'] [-/php-]/library/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="[-php-] echo $GLOBALS['webroot'] [-/php-]/library/js/jquery.fancybox.pack.js"></script>
<link rel="stylesheet" type="text/css" href="[-php-]echo $GLOBALS['webroot'].'/interface/themes/jquery.fancybox.css?v=2.1.5';[-/php-]" media="screen"/>
<script type="text/javascript" src="[-php-] echo $GLOBALS['webroot'] [-/php-]/library/dialog.js"></script>
<script type="text/javascript" src="[-php-] echo $GLOBALS['webroot'] [-/php-]/library/textformat.js"></script>
<script type="text/javascript" src="[-php-] echo $GLOBALS['webroot'] [-/php-]/library/js/calendarDirectSelect.js"></script>

[-/if-]

<script language='JavaScript'>

 var mypcc = '[-php-] echo $GLOBALS['phone_country_code'] [-/php-]';

 // This is called from the event editor popup.
 function refreshme() {
  top.restoreSession();
  MySubmitForm();
 }

 function newEvt(startampm, starttimeh, starttimem, eventdate, providerid, catid, source) {
   var url = 'calendar/add_edit_event.php?startampm=' + startampm +
   '&starttimeh=' + starttimeh + '&starttimem=' + starttimem +
   '&date=' + eventdate + '&userid=' + providerid + '&catid=' + catid + 
   '&src=' + source
   [-php-]
    if(isset($_SESSION[pid]))
        {
            if($_SESSION[pid]>0)
                {
                    echo "+'&patientid=$_SESSION[pid]'";
                }
        }
    [-/php-]
  ;
       
        parent.$.fancybox({
            href: url,
            autoSize: true,
            type: 'iframe',
            helpers: {
                overlay: {
                    opacity: 0.3,
                    css: {
                        'background': 'rgba(255, 254, 254,0.85)'
                    }
                } // overlay
            } // helpers
        }); // fancybox
 }
 
 function editEvt(startampm, starttimeh, starttimem, eventdate, providerid, catid, source) {
   var url = 'calendar/add_edit_event.php?startampm=' + startampm +
   '&starttimeh=' + starttimeh + '&starttimem=' + starttimem +
   '&date=' + eventdate + '&userid=' + providerid + '&catid=' + catid
   '&src=' + source
   [-php-]
    if(isset($_SESSION[pid]))
        {
            if($_SESSION[pid]>0)
                {
                    echo "+'&patientid=$_SESSION[pid]'";
                }
        }
    [-/php-]
  ;
       
        parent.$.fancybox({
            href: url,
            autoSize: true,
            type: 'iframe',
            helpers: {
                overlay: {
                    opacity: 0.3,
                    css: {
                        'background': 'rgba(255, 254, 254,0.85)'
                    }
                } // overlay
            } // helpers
        }); // fancybox
 }

 function timeNav(btnId, urlbtn){
 
	$.ajax({
		  type: "POST",
		  cache: false,
		  url: urlbtn, // preview.php
		  data: $("#theform").serializeArray(), // all form fields
		  success: function (data) {
			$("#info").html(data);
		  } // success
		}); // ajax
 
 }
 
 function oldEvt(eventdate, eventid, pccattype) {
  dlgopen('calendar/add_edit_event.php?date='+eventdate+'&eid=' + eventid+'&prov=' + pccattype, '_blank', 575, 375);
 }

 function goPid(pid) {
 top.restoreSession();
 $.ajax({
		  type: "POST",
		  cache: false,
		  url: '../patient_file/summary/demographics.php?set_pid=' + pid, 
		  data: '', // all form fields
		  success: function (data) {
			$("#info").html(data);
		  } // success
		}); // ajax
 }

 function GoToToday(theForm){
  var todays_date = new Date();
  var theMonth = todays_date.getMonth() + 1;
  theMonth = theMonth < 10 ? "0" + theMonth : theMonth;
  theForm.jumpdate.value = todays_date.getFullYear() + "-" + theMonth + "-" + todays_date.getDate();
  $("#viewtype").val('day');
  top.restoreSession();
  MySubmitForm();
 }

</script>
<script type="text/javascript">
	$(document).ready(function() {
		$('.iframe_cal').click(function(e){
			e.preventDefault();
			parent.$.fancybox({
				href: this.href,
				autoSize : true,
				type: 'iframe',
				helpers: {
					overlay: {
						opacity: 0.3,
						css : {
							'background' : 'rgba(238,238,238,0.85)'
						} 
					} // overlay
				} // helpers
			}); // fancybox
		}); // click 	
	}); // ready 
	
	/* edit an existing event */
    var EditEvent = function(eObj) {
        //alert ('editing '+eObj.id);
        // split the object ID into date and event ID
        objID = eObj.id;
        
        var parts = new Array();
        parts = objID.split("-");
        // call the oldEvt function to bring up the event editor
        //oldEvt(parts[0], parts[1], parts[2]);
        
        
        var url = "calendar/add_edit_event.php?date="+parts[0]+"&eid=" +parts[1]+"&prov="+parts[2]+"&editOn=1&src=2"
        
        [-php-]
            if(isset($_SESSION[pid])){
                if($_SESSION[pid]>0){
                    echo "+'&patientid=$_SESSION[pid]'";
                }
            }
        [-/php-]
        ;
       
        parent.$.fancybox({
            href: url,
            autoSize: true,
            type: 'iframe',
            helpers: {
                overlay: {
                    opacity: 0.3,
                    css: {
                        'background': 'rgba(255, 254, 254,0.85)'
                    }
                } // overlay
            } // helpers
        }); // fancybox
        
        
        return true;
    }
	
	/* change the provider(s)
     */
    var ChangeProviders = function (eventObject) {
                
		MySubmitForm();
    }

    /* change the calendar view
     */
    var ChangeView = function (eventObject) {
        if (eventObject.id == "dayview") {
            $("#viewtype").val('day');
        }
        else if (eventObject.id == "weekview") {
            $("#viewtype").val('week');
        }
        else if (eventObject.id == "monthview") {
            $("#viewtype").val('month');
        }
        else if (eventObject.id == "yearview") {
            $("#viewtype").val('year');
        }
		//SubmitForm();
                MySubmitForm();
    }
    

    function updateDate(date){
        $data = 'newdate=' + date
        $.ajax({
		  type: "POST",
		  cache: false,
		  url: 'calendar/updatedate.php?', // preview.php
		  data: $data,
		  success: function (output) {
			alert(output);
		  } // success
		}); // ajax
    }
	
	function SubmitForm(){
		$.ajax({
		  type: "POST",
		  cache: false,
		  url: $("#theform").attr('action'), // preview.php
		  data: $("#theform").serializeArray(), // all form fields
		  success: function (data) {
			$("#info").html(data);
		  } // success
		}); // ajax
	}
        
        
    function ChangeViewDay (date){
        $("#viewtype").val('day');  
        $extradata = "";
            
            if( $('#pc_usernamelist :selected').length > 0){
                //build an array of selected values
                var selectednumbers = [];
                $('#pc_usernamelist :selected').each(function(i, selected) {
                    selectednumbers[i] = $(selected).val();
                    $data = "&pc_username[]="+selectednumbers[i];
                    $extradata +=$data;
                });
                //post data to handler script. note the JSON.stringify call
                
            }
            
            $extradata += "&Date="+date;
            
		$.ajax({
		  type: "POST",
		  cache: false,
		  url: $("#theform").attr('action'), // preview.php
		  data: $("#theform").serialize() + $extradata, // all form fields
		  success: function (data) {
			$("#info").html(data);
		  } // success
		}); // ajax
    }
    
        function MySubmitForm(){
            $extradata = "";
            if( $('#pc_usernamelist :selected').length > 0){
                //build an array of selected values
                var selectednumbers = [];
                $('#pc_usernamelist :selected').each(function(i, selected) {
                    selectednumbers[i] = $(selected).val();
                    $data = "&pc_username[]="+selectednumbers[i];
                    $extradata +=$data;
                });
                //post data to handler script. note the JSON.stringify call
                
            }
                  
		$.ajax({
		  type: "POST",
		  cache: false,
		  url: $("#theform").attr('action'), // preview.php
		  data: $("#theform").serialize() + $extradata, // all form fields
		  success: function (data) {
			$("#info").html(data);
		  } // success
		}); // ajax
        }

</script>
</head>
[-php-]
/* in an attempt to not 'rock the boat' too much the concurrent_layout
 * color scheme remains unchanged
 */
if ($GLOBALS['concurrent_layout']) {
    echo "<body style='width:960px;margin:0 auto;background-color:".$GLOBALS['style']['BGCOLOR2']."'>";
}
else {
    echo "<body class='body_top'>";
}
[-/php-]

<!--<h1>david</h1>-->
